package org.exia.minisig.services;

import java.util.ArrayList;

import org.exia.minisig.model.dao.ItineraryDAO;
import org.exia.minisig.model.object.Itinerary;

public class ItineraryManager {
 //CONSTRUCTOR
 public ItineraryManager() {
  initializeVar();
 }
 public void initializeVar(){
  
 }
 //GET & SET
 public ArrayList<Itinerary> getAll(){
  ItineraryDAO itineraryDAO = new ItineraryDAO();
  ArrayList<Itinerary> listItinerary = new ArrayList<>();
  for (Object newObject : itineraryDAO.getList()) {
   listItinerary.add((Itinerary)newObject);
  }
  return listItinerary; 
 }
 
 
 public void addItinerary(Itinerary _itinerary){
	  ItineraryDAO itinerary = new ItineraryDAO(_itinerary);
	  //1 - Ajout a la table news
	  itinerary.add();
	  itinerary.setID();
	  //2- Ajout des image
	  itinerary.linkImages();
	  //3-Ajout URL
	  itinerary.linkURL();
 }
 public void removeItinerary(Itinerary _itinerary){
  ItineraryDAO itinerary = new ItineraryDAO(_itinerary);
  
  itinerary.deleteUrl();
  itinerary.deleteImg();
  itinerary.delete();
 }
 public void updateItinerary(Itinerary _itinerary){
	 ItineraryDAO itinerary = new ItineraryDAO(_itinerary);
	 //1. Supression des URL + IMG
	 itinerary.deleteUrl();
	 itinerary.deleteImg();
	 //2. Update
	 itinerary.update();
	 //3.relier Image
	 itinerary.linkImages();
	 itinerary.linkURL();
 }
}